# $Id: PKGBUILD 66211 2012-02-23 03:24:22Z spupykin $
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Maintainer: Pierre Schmitz <pierre@archlinux.de>

pkgname=logwatch
pkgver=7.4.0
pkgrel=2
arch=('any')
pkgdesc="Logwatch is a customizable log analysis system."
url="http://www.logwatch.org/"
depends=('perl' 'cron')
optdepends=('perl-date-manip: human readable dates')
license=('custom')
backup=(etc/logwatch/conf/logwatch.conf
	etc/logwatch/conf/ignore.conf
	etc/logwatch/conf/override.conf)
source=(http://downloads.sourceforge.net/project/logwatch/logwatch-$pkgver/logwatch-$pkgver.tar.gz
	rsyslog-messages.patch)
md5sums=('b776466fb0633b486a41cf5aafcd9d12'
         'e7f543259ae4f9bb0f4f1ce0638f5800')

build() {
	cd $srcdir/$pkgname-$pkgver

#	sed -i 's#^Print = Yes#Print = No#' conf/logwatch.conf
	(cd scripts/shared/ && patch -p6 applystddate <$srcdir/rsyslog-messages.patch)

	install -m 0755 -d $pkgdir/usr/share/logwatch
	install -m 0755 -d $pkgdir/usr/share/logwatch/dist.conf
	install -m 0755 -d $pkgdir/usr/share/logwatch/dist.conf/logfiles
	install -m 0755 -d $pkgdir/usr/share/logwatch/dist.conf/services
	install -m 0755 -d $pkgdir/usr/share/logwatch/default.conf
	install -m 0755 -d $pkgdir/usr/share/logwatch/default.conf/logfiles
	install -m 0755 -d $pkgdir/usr/share/logwatch/default.conf/services
	install -m 0755 -d $pkgdir/usr/share/logwatch/default.conf/html
	install -m 0755 -d $pkgdir/usr/share/logwatch/scripts
	install -m 0755 -d $pkgdir/usr/share/logwatch/scripts/logfiles
	install -m 0755 -d $pkgdir/usr/share/logwatch/scripts/services
	install -m 0755 -d $pkgdir/usr/share/logwatch/scripts/shared
	install -m 0755 -d $pkgdir/usr/share/logwatch/lib

	install -m 0644 README $pkgdir/usr/share/logwatch/README
	install -m 0644 HOWTO-Customize-LogWatch $pkgdir/usr/share/logwatch/HOWTO-Customize-LogWatch
	install -m 0644 conf/*.conf $pkgdir/usr/share/logwatch/default.conf
	install -m 0644 conf/logfiles/* $pkgdir/usr/share/logwatch/default.conf/logfiles
	install -m 0644 conf/services/* $pkgdir/usr/share/logwatch/default.conf/services
	install -m 0644 conf/html/* $pkgdir/usr/share/logwatch/default.conf/html
	install -m 0755 scripts/logwatch.pl $pkgdir/usr/share/logwatch/scripts/logwatch.pl
	for i in scripts/logfiles/* ; do
		if [ `ls $i | grep -v CVS | wc -l` -ne 0 ] ; then
		install -m 0755 -d $pkgdir/usr/share/logwatch/$i
		install -m 0644 $i/* $pkgdir/usr/share/logwatch/$i
		fi
	done
	install -m 0644 scripts/shared/* $pkgdir/usr/share/logwatch/scripts/shared
	install -m 0644 scripts/services/* $pkgdir/usr/share/logwatch/scripts/services
	install -m 0644 lib/* $pkgdir/usr/share/logwatch/lib

	install -m 0755 -d $pkgdir/etc/logwatch
	install -m 0755 -d $pkgdir/etc/logwatch/scripts
	install -m 0755 -d $pkgdir/etc/logwatch/conf
	install -m 0755 -d $pkgdir/etc/logwatch/conf/logfiles
	install -m 0755 -d $pkgdir/etc/logwatch/conf/services
	install -m 0755 -d $pkgdir/etc/logwatch/conf/html

	touch $pkgdir/etc/logwatch/conf/logwatch.conf
	touch $pkgdir/etc/logwatch/conf/ignore.conf
	touch $pkgdir/etc/logwatch/conf/override.conf

	install -m 0755 -d $pkgdir/usr/share/man/man8/
	install -m 0644 logwatch.8 $pkgdir/usr/share/man/man8/

	install -m 0755 -d $pkgdir/etc/cron.daily/
	install -m 0755 -d $pkgdir/usr/sbin/
	ln -s /usr/share/logwatch/scripts/logwatch.pl $pkgdir/usr/sbin/logwatch
	ln -s /usr/share/logwatch/scripts/logwatch.pl $pkgdir/etc/cron.daily/0logwatch

	install -m 0755 -d $pkgdir/var/cache/logwatch

	install -m 0755 -d $pkgdir/usr/share/licenses/$pkgname/
	install -m 0644 LICENSE $pkgdir/usr/share/licenses/$pkgname/
}
